Socket
Socket
Sign inDemoInstall

@mamba/core

Package Overview
Dependencies
0
Maintainers
5
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mamba/core


Version published
Weekly downloads
30
decreased by-75%
Maintainers
5
Created
Weekly downloads
 

Changelog

Source

9.7.0 (2023-06-09)

⚠ BREAKING CHANGES

  • 🧨 freeze keystroke changed
  • 🧨 onupdate uses render methods now
  • 🧨 event handler prop is not telemetryEmitType

Features

  • 🎸 add method render (930a0a9)
  • 🎸 add rmeotejs automatic tag (497321f)
  • 🎸 add telemetry metadata on flatlist (2e937ae)
  • 🎸 controls flatlist rendered display (hide/show) (506ae69)
  • 🎸 extend event data to add telemetryEmitType (58e5cb5)

Bug Fixes

  • 🐛 add telemetry emit type to the keystroke (b99d163)
  • 🐛 fix keyboard main field (8f835de)
  • 🐛 fix remotejs value (4e0f60c)
  • 🐛 send keyCode through synthetic mouse event (4ee70ee)
  • 🐛 several critial keystroke bugs along with configmation dialog events (47c78a0)

Code Refactoring

Readme

Source

Core

Pacotes principais do mamba com alguns códigos essenciais e compartilhados.

Extend

Estenda um driver com o driver base.

import extendDriver from '@mamba/core/index.js';

/* Optional Driver wrapper path */
import wrappers from './wrappers.js';

export default extendDriver(driverTarget, wrappers);

Currency

Fornece constante da moeda no POS.

Limite máximo

import { CURRENCY } from '@mamba/core';

CURRENCY.LIMIT; // 999999.99

Keymap

Fornece os mapas-chave e nomes-chave específicos do POS.

KEY_NAMES

import { KEYBOARD } from '@mamba/core';

const { KEY_NAMES, KEY_NAMES_LIST } = KEYBOARD;

KEY_NAMES.ENTER; // 'enter'
KEY_NAMES_LIST; // ['CLOSE', 'BACK', 'ENTER', 'HELP', 'SHORTCUTS', 'SPACE', 'KEYUP', 'ARROW_UP', 'KEYDOWN', 'ARROW_DOWN', 'F24', 'F23', 'KEY_0', 'KEY_1', 'KEY_2', 'KEY_3', 'KEY_4', 'KEY_5', 'KEY_6', 'KEY_7', 'KEY_8', 'KEY_9']

Values:

{
  CLOSE: 'close',
  BACK: 'back',
  ENTER: 'enter',
  HELP: 'help',
  SHORTCUTS: 'shortcuts',
  SPACE: 'space',
  F24: 'F24',
  F23: 'F23',
  KEY_0: '0',
  KEY_1: '1',
  KEY_2: '2',
  KEY_3: '3',
  KEY_4: '4',
  KEY_5: '5',
  KEY_6: '6',
  KEY_7: '7',
  KEY_8: '8',
  KEY_9: '9',

  /**
   * @deprecated Use `ARROW_UP`
   */
  KEYUP: 'keyup',
  ARROW_UP: 'keyup',
  /**
   * @deprecated Use `ARROW_DOWN`
   */
  KEYDOWN: 'keydown',
  ARROW_DOWN: 'keydown',
}

KEY_CODES

import { KEYBOARD } from '@mamba/core';

const { KEY_CODES, KEY_CODES_LIST } = KEYBOARD;

KEY_CODES.ENTER; // 13
KEY_CODES_LIST; // [13, 8, 8, 27, 17, 16, 134, 135, 32, 38, 40, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57]

Values:

{
  BACK: 8,
  ENTER: 13,
  SHORTCUTS: 16,
  HELP: 17,
  CLOSE: 27,
  SPACE: 32,
  ARROW_UP: 38,
  ARROW_DOWN: 40,
  KEY_0: 48,
  KEY_1: 49,
  KEY_2: 50,
  KEY_3: 51,
  KEY_4: 52,
  KEY_5: 53,
  KEY_6: 54,
  KEY_7: 55,
  KEY_8: 56,
  KEY_9: 57,
  F23: 134,
  F24: 135,

  /**
   * @deprecated Use `ARROW_UP`
   */
  KEYUP: 38,
  /**
   * @deprecated Use `ARROW_DOWN`
   */
  KEYDOWN: 40,
}

KEYMAP

Códigos de chave mapeados para nomes de chave

import { KEYBOARD } from '@mamba/core';

const { KEY_MAP, KEY_NAMES, KEY_1 } = KEYBOARD;

KEY_MAP.13; // 'Enter'

KEY_MAP[KEY_NAMES.ENTER]; // 'Enter'
KEY_MAP[KEY_1]; // '1'

Values:

{
  "8": "back",
  "13": "enter",
  "16": "shortcuts",
  "17": "help",
  "27": "close",
  "32": "space",
  "38": "keyup",
  "40": "keydown",
  "48": "0",
  "49": "1",
  "50": "2",
  "51": "3",
  "52": "4",
  "53": "5",
  "54": "6",
  "55": "7",
  "56": "8",
  "57": "9",
  "134": "F23",
  "135": "F24"
}

Usage example

Digamos que você queira fazer alguma ação na tela com base em alguma chave POS.

<svelte:window on:keyup="onKeyup(event)" />

<script>
  import Keyboard from '@mamba/keyboard/api/index.js';
  import { KEYBOARD } from '@mamba/core';

  export default {
    methods: {
      /**
       * @description handle physical keyboard events
       * @param {KeyboardEvent} event
       */
      onKeyup(event) {
        const { keyCode } = event;
        const { KEY_NAMES, KEY_CODES } = KEYBOARD;

        const keyName = Keyboard.getKeyName(keyCode);

        if (keyName === KEY_NAMES.BACK) {
          // Do something with back key name
        } else if (keyName === KEY_NAMES.ENTER) {
          // Do something with enter key name
        }

        // Using key code directly
        if (keyCode === KEY_CODES.SHORTCUTS) {
          // Do something with shortcut key code
        }
      },
    },
  };
</script>

FAQs

Last updated on 09 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc